package com.xci.core.handler;

import com.xci.core.helper.HtmlHelper;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class FreemarkerViewHandlerInterceptor implements HandlerInterceptor {
    @Resource
    private HtmlHelper htmlHelper;

    /**
     * 请求处理之后进行调用，但是在视图被渲染之前（Controller方法调用之后）
     */
    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) {
        httpServletRequest.setAttribute("helper", htmlHelper);
    }
}